import Vue from 'vue'
import App from './App'
import store from '@/store';
// #ifdef H5
import { Cookies } from '@/lib/js.cookie';
Vue.prototype.$cookie = Cookies
// #endif
Vue.config.productionTip = false
import '@/static/fonts/iconfont.css';
import '@/static/scss/reset.scss';
import '@/static/fonts/iconfont-weapp/iconfont-weapp-icon.css';
import uView from '@/uni_modules/uview-ui';
Vue.use(uView);

const vuexStore = require('@/store/$u.mixin.js');
Vue.mixin(vuexStore);

App.mpType = 'app'

const app = new Vue({
  store,
  ...App
})
// #ifdef MP-ALIPAY
/*const myFirstPromise = () => {
  return new Promise(function(resolve, reject) {
    my.getRunScene({
      success(result) {
        resolve(result.envVersion);
      },
    })
  });
}
myFirstPromise().then((res) => {
  require('@/config/request.js')(app, res)
})*/
//#endif
// #ifdef MP-WEIXIN
// require('@/config/request.js')(app)
// #endif
require('@/config/request.js')(app)

app.$mount()

// 根据缓存中是否存在'vuex_memberInfo','vuex_memberCompanyInfo'，'vuex_crmCustomerInfos', 'vuex_memberLevelResp'参数去获取客户信息
import { getLoginInfoFn } from '@/common/common'
const {
  vuex_loginStatus,
  vuex_accountInfo,
  vuex_memberInfo,
  vuex_memberCompanyInfo,
  vuex_crmCustomerInfos,
  vuex_memberLevelResp
} = app
const getCustomerInfoFn = () => {
  if (!vuex_memberInfo || (vuex_memberInfo && Object.keys(vuex_memberInfo) == 0) || !vuex_memberCompanyInfo || (vuex_memberCompanyInfo && Object.keys(vuex_memberCompanyInfo) == 0) || !vuex_crmCustomerInfos || (vuex_crmCustomerInfos && Object.keys(vuex_crmCustomerInfos) == 0) || !vuex_memberLevelResp || (vuex_memberLevelResp && Object.keys(vuex_memberLevelResp) == 0)) {
    getLoginInfoFn()
  }
}
if (vuex_loginStatus && vuex_accountInfo.memberId) {
  getCustomerInfoFn(vuex_accountInfo.memberId)
}
